Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
@types/moment-timezone
Advanced tools
Stub TypeScript definitions entry for moment-timezone, which provides its own types definitions
@types/moment-timezone provides TypeScript type definitions for the moment-timezone library, which is an extension of moment.js for handling time zones. It allows developers to work with dates and times in different time zones, convert between them, and perform various date-time manipulations with type safety.
Time Zone Conversion
Convert a date-time from one time zone to another. In this example, a date-time in 'America/New_York' is converted to 'Europe/London'.
const moment = require('moment-timezone');
const date = moment.tz('2023-10-01 12:00', 'America/New_York');
const convertedDate = date.tz('Europe/London');
console.log(convertedDate.format());
Get Time Zone Names
Retrieve a list of all available time zone names. This can be useful for populating a dropdown menu or validating user input.
const moment = require('moment-timezone');
const timeZones = moment.tz.names();
console.log(timeZones);
Get Time Zone Offset
Get the UTC offset for a specific time zone. This can be useful for displaying the offset to users or performing calculations.
const moment = require('moment-timezone');
const offset = moment.tz('America/New_York').utcOffset();
console.log(offset);
Format Date-Time in Time Zone
Format a date-time string in a specific time zone. This example formats a date-time in 'America/New_York' with a specific format.
const moment = require('moment-timezone');
const date = moment.tz('2023-10-01 12:00', 'America/New_York');
console.log(date.format('YYYY-MM-DD HH:mm:ss Z'));
date-fns-tz is an extension for date-fns that provides time zone support. It offers similar functionalities to moment-timezone, such as converting between time zones and formatting date-times. However, date-fns-tz is often preferred for its functional programming style and tree-shakable modules.
Luxon is a modern JavaScript library for working with dates and times. It provides built-in support for time zones and offers a more modern API compared to moment-timezone. Luxon is often chosen for new projects due to its better performance and smaller bundle size.
timezone-js is a library for handling time zones in JavaScript. It provides similar functionalities to moment-timezone but is less commonly used. It can be a good alternative for projects that require a lightweight solution.
This is a stub types definition for moment-timezone (https://github.com/moment/moment-timezone).
moment-timezone provides its own type definitions, so you don't need @types/moment-timezone installed!
0.5.30
2020-05-16
2020a
NOTE: You might need to un-install @types/moment-timezone. Check https://github.com/moment/moment-timezone/issues/858 for more info
FAQs
Stub TypeScript definitions entry for moment-timezone, which provides its own types definitions
We found that @types/moment-timezone demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.